package org.wang.generalcode.modules.exam.parser;

import jakarta.servlet.http.HttpServletResponse;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import org.wang.generalcode.modules.exam.pojo.entity.QuestionInfoEntity;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

@Data
public abstract  class QuestionImportResult {

    private final InputStream inputStream;
    private MultipartFile file;
    private HttpServletResponse response;

    private String errorFileUrl; // 错误提示文件路径url
    private boolean hasData = true; // 文件是否有内容
    private List<QuestionInfoEntity> successImportQuestionList; // 导入成功试题
    private List<QuestionInfoEntity> failImportQuestionList; // 导入失败试题
    private String errorMsg; // 错误提示信息

    public QuestionImportResult(MultipartFile file, HttpServletResponse response) throws IOException {
        this.file = file;
        this.inputStream = file.getInputStream();
        this.response = response;
    }

    public QuestionImportResult(InputStream inputStream) {
        this.inputStream = inputStream;
    }

    public QuestionImportResult(MultipartFile file) throws IOException {
        this.file = file;
        this.inputStream = file.getInputStream();
    }

    public abstract void readTemplate();
}
